//
//  TempFileManager.m
//  gdemm
//
//  Created by 乔明超 on 16/5/6.
//  Copyright © 2016年 Goldencis. All rights reserved.
//

#import "TempFileManager.h"
#import "FileUtil.h"
@interface TempFileManager()
@property (nonatomic,copy) NSString *mPrivateTmpDir;
@end
@implementation TempFileManager
static TempFileManager *mInstance;
- (instancetype)init
{
    self = [super init];
    if (self) {
        self.mPrivateTmpDir = [self getTmpFilePath];
    }
    return self;
}
+ (instancetype)getInstance{
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        mInstance = [[self alloc]init];
    });
    return mInstance;
    
}

-(NSString *)getTmpFilePath{
    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    NSString *path = paths[0];
    NSString *tmpPath = [path stringByAppendingPathComponent:@"tmp"];
    if (![FileUtil isFileExistWithFilePath:tmpPath]) {
        [FileUtil mkdirWithPath:tmpPath];
    }
    
    return tmpPath;
    

}

- (NSString *)getPrivateTmpDirWihtFileNme:(NSString *)fileName{
    return [self.mPrivateTmpDir stringByAppendingPathComponent:fileName];
}
@end
